package com.usefullc.crawler.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.usefullc.crawler.domain.ActiveMainInstance;

public interface ActiveMainInstanceMapper extends BaseMapper<ActiveMainInstance> {

//useful_auto_generate_section_start


    //useful_auto_generate_section_end
//@Query(value = "update `crawler_active_main_instance` t set t.successNum = t.successNum + 1,t.gmtModified=now(6) where t.id = ?1 ",nativeQuery = true)
    int incrSuccessNum(Long id);

    //    @Query(value = "update `crawler_active_main_instance` t set t.successNum = t.successNum - ?2,t.gmtModified=now(6) where t.id = ?1 ",nativeQuery = true)
    int decrSuccessNum(Long id, int num);

    //    @Query(value = "update `crawler_active_main_instance` t set t.failNum = t.failNum + 1,t.gmtModified=now(6) where t.id = ?1 ",nativeQuery = true)
    int incrFailNum(Long id);

    //    @Query(value = "update `crawler_active_main_instance` t set t.status = 1,t.gmtModified=now(6) where t.id = ?1 and t.successNum >= t.totalNum ",nativeQuery = true)
    int updateToSuccess(Long id);

    //    @Query(value = "update `crawler_active_main_instance` t set t.status = 0,t.gmtModified=now(6) where t.id = ?1 and t.successNum >= t.totalNum ",nativeQuery = true)
    int updateToFail(Long id);
}
